package com.woniuxy.controller;

import com.woniuxy.entity.KillBook;
import com.woniuxy.service.SecKillService;
import com.woniuxy.util.ResponseData;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author ：CuiYC
 * @description：
 * @date ：Created in 2025/3/18 11:41
 * @modified By：
 */
@RestController
@RequestMapping("/seckill")
@AllArgsConstructor
public class KillController {

    private SecKillService secKillService;
    /**
     * 接收书籍信息，把该书籍插入秒杀表
     * 再放入Redis中
     */
    @PostMapping("/addKillBook")
    public ResponseData<?> addKillBook(@RequestBody KillBook killBook) {

        return secKillService.addKillBook(killBook);
    }

    @GetMapping("/queryKillBook")
    public ResponseData<?> queryKillBook() {
        return secKillService.queryKillBook();
    }

    @GetMapping("/queryDetail/{bookId}")
    public ResponseData<?> queryDetail(@PathVariable("bookId") Integer bookId) {
        return secKillService.queryDetail(bookId);
    }

    @GetMapping("/startKill/{bookId}")
    public ResponseData<?> startKill(@PathVariable("bookId") Integer bookId) {
        return secKillService.startKill(bookId);
    }
}
